<%@ Page Language="VB" MasterPageFile="~/Provider/MasterPage.master" AutoEventWireup="false" CodeFile="Edit.aspx.vb" Inherits="Provider_Users_Edit" title="Datos del usuario" Theme="Granite" %>

<%@ Register Src="../../Shared/Error.ascx" TagName="Error" TagPrefix="uc1" %>
<%@ Register Assembly="ECGControls" Namespace="ECGControls" TagPrefix="ecg" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainCopy" Runat="Server">
    <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>
        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Width="100%">
            <ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
                <ContentTemplate>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
<asp:DetailsView id="dvUser" runat="server" Width="401px" DataSourceID="dsUser" AutoGenerateRows="False" __designer:wfdid="w4" OnModeChanging="dvUser_ModeChanging" Height="50px"><Fields>
<asp:BoundField DataField="UserId" HeaderText="ID:" ReadOnly="True" InsertVisible="False" SortExpression="UserId"></asp:BoundField>
<asp:BoundField DataField="UserName" HeaderText="Nombre:" SortExpression="UserName"></asp:BoundField>
<asp:TemplateField HeaderText="Tenant:" SortExpression="TenantId"><EditItemTemplate>
                    <ecg:ComboList runat="server" ID="cboTenant" DAOType="Security.Data.TenantDAO, Security.Data" SelectedValue='<%# Bind("TenantId") %>'></ecg:ComboList>
                
</EditItemTemplate>
<InsertItemTemplate>
<ecg:ComboList id="cboTenant" runat="server" __designer:wfdid="w10" DAOType="Security.Data.TenantDAO, Security.Data" SelectedValue='<%# Bind("TenantId") %>'></ecg:ComboList>
</InsertItemTemplate>
<ItemTemplate>
<ecg:Descriptor id="desTenant" runat="server" __designer:wfdid="w9" EntityId='<%# Bind("TenantId") %>' DAOType="Security.Data.TenantDAO, Security.Data"></ecg:Descriptor> 
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Applicaci&#243;n:" SortExpression="ApplicationId"><EditItemTemplate>
                    <ecg:ComboList runat="server" ID="cboApplication" DAOType="Security.Data.ApplicationDAO, Security.Data" SelectedValue='<%# Bind("ApplicationId") %>'></ecg:ComboList>
                
</EditItemTemplate>
<InsertItemTemplate>
                    <ecg:ComboList runat="server" ID="cboApplication" DAOType="Security.Data.ApplicationDAO, Security.Data" SelectedValue='<%# Bind("ApplicationId") %>'></ecg:ComboList>
                
</InsertItemTemplate>
<ItemTemplate>
                    <ecg:Descriptor runat="server" ID="desApplication" DAOType="Security.Data.ApplicationDAO, Security.Data" EntityId='<%# Bind("ApplicationId") %>'></ecg:Descriptor>
                
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Password" HeaderText="Password:" SortExpression="Password"></asp:BoundField>
<asp:BoundField DataField="Email" HeaderText="E-Mail:" SortExpression="Email"></asp:BoundField>
<asp:CheckBoxField DataField="Activated" HeaderText="Activo:" SortExpression="Activated"></asp:CheckBoxField>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True"></asp:CommandField>
</Fields>
</asp:DetailsView> 
</ContentTemplate>
</asp:UpdatePanel>
    <asp:ObjectDataSource ID="dsUser" runat="server" DataObjectTypeName="Security.Entities.User"
        DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetById" TypeName="Security.Data.UserDAO" UpdateMethod="Update">
        <SelectParameters>
            <asp:QueryStringParameter Name="id" QueryStringField="id" />
        </SelectParameters>
    </asp:ObjectDataSource>
                    &nbsp; &nbsp;
                </ContentTemplate>
                <HeaderTemplate>
                    Datos
                </HeaderTemplate>
            </ajaxToolkit:TabPanel>
            <ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2" Width="100%">
                <HeaderTemplate>
                    Patentes
                </HeaderTemplate>
                <ContentTemplate>
                    <table>
                        <tr>
                            <td colspan="2">
                                <br />
                                <asp:UpdatePanel id="UpdatePanel3" runat="server">
                                    <contenttemplate>
<asp:TextBox id="txtNewRole" runat="server"></asp:TextBox><asp:LinkButton id="btnAddRole" runat="server">Agregar</asp:LinkButton> <ajaxToolkit:AutoCompleteExtender id="AutoCompleteExtender1" runat="server" TargetControlID="txtNewRole" UseContextKey="True" ServicePath="~/WS/Autocomplete.asmx" ServiceMethod="GetRoles" MinimumPrefixLength="2" CompletionInterval="500" EnableCaching="true" CompletionSetCount="12">
                                </ajaxToolkit:AutoCompleteExtender> 
</contenttemplate>
                                </asp:UpdatePanel></td>
                        </tr>
                        <tr>
                            <td style="width: 100px">
                                &nbsp;
                                <asp:UpdatePanel id="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                    <contenttemplate>
<asp:GridView id="grdUserRoles" runat="server" DataKeyNames="RoleId" AutoGenerateColumns="False"><Columns>
<asp:CommandField SelectImageUrl="~/Shared/img/edit.gif" ShowSelectButton="True" ButtonType="Image"></asp:CommandField>
<asp:BoundField DataField="RoleId" HeaderText="RoleId" SortExpression="RoleId" Visible="False"></asp:BoundField>
<asp:BoundField DataField="RoleName" HeaderText="Patentes" SortExpression="RoleName"></asp:BoundField>
</Columns>
</asp:GridView> 
</contenttemplate>
                                    <triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddRole" EventName="Click"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="dvRole" EventName="ItemDeleting"></asp:AsyncPostBackTrigger>
</triggers>
                                </asp:UpdatePanel>&nbsp;
                            </td>
                            <td style="width: 100px">
                                &nbsp;
                                <asp:UpdatePanel id="UpdatePanel4" runat="server" UpdateMode="Conditional">
                                    <contenttemplate>
<asp:DetailsView id="dvRole" runat="server" Width="125px" AutoGenerateRows="False" DataSourceID="dsRole" OnItemDeleting="dvRole_ItemDeleting">
<Fields>
<asp:BoundField DataField="RoleName" HeaderText="Nombre:" SortExpression="RoleName"></asp:BoundField>
<asp:BoundField DataField="ApplicationId" HeaderText="Application:" SortExpression="ApplicationId"></asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Description:" SortExpression="Description"></asp:BoundField>
<asp:CommandField DeleteText="Quitar patente" ShowDeleteButton="True" ButtonType="Button"></asp:CommandField>
</Fields>
</asp:DetailsView> 
</contenttemplate>
                                    <triggers>
<asp:AsyncPostBackTrigger ControlID="grdUserRoles" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
</triggers>
                                </asp:UpdatePanel>
                                <asp:ObjectDataSource ID="dsRole" runat="server" OldValuesParameterFormatString="original_{0}"
                                    SelectMethod="GetById" TypeName="Security.Data.RoleDAO">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="grdUserRoles" Name="id" PropertyName="SelectedValue" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </ajaxToolkit:TabPanel>
            <ajaxToolkit:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3">
                <HeaderTemplate>
                    Familias
                </HeaderTemplate>
                <ContentTemplate>
                    <table>
                        <tr>
                            <td colspan="2">
                                <br />
                                <asp:UpdatePanel id="UpdatePanel5" runat="server">
                                    <contenttemplate>
                                        <asp:TextBox ID="txtNewGroup" runat="server"></asp:TextBox><asp:LinkButton ID="btnAddGroup"
                                            runat="server" OnClick="btnAddGroup_Click">Agregar</asp:LinkButton>
                                        <ajaxToolkit:AutoCompleteExtender id="AutoCompleteExtender2" runat="server" TargetControlID="txtNewGroup" UseContextKey="True" ServicePath="~/WS/Autocomplete.asmx" ServiceMethod="GetGroups" MinimumPrefixLength="2" CompletionInterval="500" EnableCaching="true" CompletionSetCount="12">
                                        </ajaxToolkit:AutoCompleteExtender>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px">
                                &nbsp;
                                <asp:UpdatePanel id="UpdatePanel6" runat="server" UpdateMode="Conditional">
                                    <contenttemplate>
                                        <asp:GridView id="grdUserGroups" runat="server" DataKeyNames="GroupId" AutoGenerateColumns="False">
                                            <Columns>
                                                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Shared/img/edit.gif" ShowSelectButton="True" />
                                                <asp:BoundField DataField="GroupId" HeaderText="GroupId" SortExpression="GroupId"
                                                    Visible="False" />
                                                <asp:BoundField DataField="GroupName" HeaderText="Groups" SortExpression="GroupName" />
                                            </Columns>
                                        </asp:GridView>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="btnAddGroup" EventName="Click" />
                                        <asp:AsyncPostBackTrigger ControlID="dvGroup" EventName="ItemDeleting" />
                                    </Triggers>
                                </asp:UpdatePanel>
                                &nbsp;&nbsp;
                                <asp:UpdatePanel id="UpdatePanel8" runat="server" UpdateMode="Conditional">
                                    <contenttemplate>
                                        <asp:GridView id="grdGroupRoles" runat="server" DataKeyNames="RoleId" AutoGenerateColumns="False">
                                            <Columns>
                                                <asp:BoundField DataField="RoleId" HeaderText="RoleId" SortExpression="RoleId" Visible="False" />
                                                <asp:BoundField DataField="RoleName" HeaderText="Patentes" SortExpression="RoleName" />
                                            </Columns>
                                        </asp:GridView>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="grdUserGroups" />
                                    </Triggers>
                                </asp:UpdatePanel>
                                <asp:ObjectDataSource ID="dsRolesInGroup" runat="server" DataObjectTypeName="Security.Entities.Role" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetByGroup" TypeName="Security.Data.RoleDAO" UpdateMethod="Update">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="grdUserGroups" Name="groupId" PropertyName="SelectedValue" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </td>
                            <td style="width: 100px">
                                &nbsp;
                                <asp:UpdatePanel id="UpdatePanel7" runat="server" UpdateMode="Conditional">
                                    <contenttemplate>
                                        <asp:DetailsView id="dvGroup" runat="server" Width="125px" AutoGenerateRows="False" DataSourceID="dsGroup" OnItemDeleting="dvGroup_ItemDeleting">
                                            <Fields>
                                                <asp:BoundField DataField="GroupName" HeaderText="Nombre:" SortExpression="GroupName" />
                                                <asp:BoundField DataField="ApplicationId" HeaderText="Application:" SortExpression="ApplicationId" />
                                                <asp:BoundField DataField="Description" HeaderText="Description:" SortExpression="Description" />
                                                <asp:CommandField ButtonType="Button" DeleteText="Quitar patente" ShowDeleteButton="True" />
                                            </Fields>
                                        </asp:DetailsView>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="grdUserGroups" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                </asp:UpdatePanel>
                                <asp:ObjectDataSource ID="dsGroup" runat="server" OldValuesParameterFormatString="original_{0}"
                                    SelectMethod="GetById" TypeName="Security.Data.GroupDAO">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="grdUserGroups" Name="id" PropertyName="SelectedValue" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </ajaxToolkit:TabPanel>
        </ajaxToolkit:TabContainer>&nbsp;
        <br />
</asp:Content>

